﻿<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:common="using:PlayToExample.Common"
    x:Name="PageRoot"
    x:Class="PlayToExample.PicturesPage"
    mc:Ignorable="d">

    <Page.Resources>
        <x:String x:Key="AppName">Sharing Pictures</x:String>
        <common:NullToVisibilityConverter x:Key="NullToVisibilityConverter" NullVisibility="Visible"/>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="1" Margin="120, 0, 40, 40">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="160"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="0" Margin="0,0,20,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Button Grid.Row="0" Content="Select Pictures" HorizontalAlignment="Stretch" Click="HandleSelectPicturesClicked"/>
                <ListView Grid.Row="1" x:Name="ImagesListView" SelectionChanged="HandleImagesListViewSelectionChanged">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Image Source="{Binding}"/>
                            </Grid>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </Grid>
            <Border Grid.Column="1" BorderBrush="Black" BorderThickness="1">
                <Grid>
                    <Image Source="Assets/SplashScreen.png" HorizontalAlignment="Center" Visibility="{Binding ElementName=SelectedImageContainer, Path=Content, Converter={StaticResource NullToVisibilityConverter} }"/>
                    <ContentControl x:Name="SelectedImageContainer" HorizontalContentAlignment="Center" />
                    <!--<Image x:Name="ImageElement" Source="{Binding SelectedItem, ElementName=ImagesListView}" />-->
                </Grid>
            </Border>
        </Grid>

        <!-- Back button and page title -->
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="BackButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
				Style="{StaticResource NavigationBackButtonNormalStyle}"
				VerticalAlignment="Top"
				AutomationProperties.Name="Back"
				AutomationProperties.AutomationId="BackButton"
				AutomationProperties.ItemType="Navigation Button"/>
            <TextBlock x:Name="PageTitle" Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
				IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
        </Grid>
    </Grid>
</Page>
